#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClick);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
    this->setWindowTitle("修改标题1");
    qDebug() << "修改标题1";
}

void Widget::handleClick2()
{
    this->setWindowTitle("修改标题2");
    qDebug() << "修改标题2";
}


void Widget::on_pushButton_2_clicked()
{
    //1.先断开pushButton原来的信号槽
    //如果没有disconnect，就会构成一个信号绑定了两个信号槽，触发信号的时候，两个槽函数都会执行
    //disconnect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClick);
    //2.重新绑定信号槽
    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handleClick2);
}

